﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;

namespace TextWeb
{
    public partial class ExcelHelper : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            DataSet ds = new DataSet();
            DataTable dt1 = new DataTable("程序生成sheet1");
            dt1.Columns.Add("Sheet1列1");
            DataTable dt2 = new DataTable("程序生成sheet2");
            dt2.Columns.Add("Sheet2列1");
            ds.Tables.Add(dt1);
            ds.Tables.Add(dt2);
            DataTable table = new DataTable();
            MemoryStream ms =  LxjCommon.ExcelHelper.RenderDataTableToExcel(ds) as MemoryStream;
            Response.AddHeader("Content-Disposition", string.Format("attachment; filename=Download.xls"));
            Response.BinaryWrite(ms.ToArray());
            ms.Close();
            ms.Dispose();
        }
    }
}
